package com.etc.RCCPA004.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.etc.RCCPA004.service.IConsultService;
import com.etc.RCCPA004.vo.ConsultMstVo;
import com.etc.common.Code;
import com.etc.common.CodeMessage;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 
 * Filename:    ConsultController.java  
 * Description: 咨询管理控制器
 * Copyright:   Copyright (c) 2018-2019 All Rights Reserved.
 * Company:     chinasofti.com Inc.
 * @author:     mazheng 
 * @version:    1.0  
 * Create at:   2020年3月15日 下午3:04:00  
 *  
 * Modification History:  
 * Date         Author      Version     Description  
 * ------------------------------------------------------------------  
 * 2020年3月15日      mazheng      1.0         1.0 Version  
 *
 */
@RestController
@RequestMapping("admin")
public class ConsultController {

    @Autowired
    IConsultService service;
    
    /**
     * 获取产品类型列表
     * @return
     */
    @GetMapping("/consult/ptlist.action")
    public CodeMessage getAllProductTypeList() {
        
//        List<Map> mlist = 
        return CodeMessage.success(Code.SUCESS, null, service.findAllProductType());
    }
    
    /**
     * 根据条件查询数据
     * @param vo
     * @return
     */
    @RequestMapping("/consult/list.action")
    public CodeMessage getAllConsultList(@RequestBody ConsultMstVo vo) {
        PageHelper.startPage(vo.getPage(), vo.getLimit());
        
        List<Map> mlist = service.findByCondition(vo);
        
        PageInfo page = new PageInfo<>(mlist);
        if (page.getTotal() == 0) {
            return CodeMessage.success(Code.SUCCESS_SHOW, "没有匹配数据", page);
        }
        return CodeMessage.success(Code.SUCESS, null, page);
    }
}
